package com.ag.hmk.service.impl;

import java.util.List;

import com.ag.bean.TbClassiccase;
import com.ag.common.IDUtil;
import com.ag.hmk.dao.HmkClassicCaseDAO;
import com.ag.hmk.service.CaseService;
/**
 * 
 * @author 黄木看
 *经典案例服务接口实现
 *
 */
public class CaseServImpl implements CaseService {

	private HmkClassicCaseDAO hmkClassicCaseDAO;
	
	/*
	 * 删除记录（by id）
	 */
	public void delete(String ccID) {
		if (ccID!=null) {
			TbClassiccase tbClassiccase = findByID(ccID);
			if (tbClassiccase!=null) {
				tbClassiccase.setA(IDUtil.DELETE);
				hmkClassicCaseDAO.attachDirty(tbClassiccase);
			}
		}
	}

	/*
	 * 查询所有记录
	 */
	public List<TbClassiccase> findAll() {
		return hmkClassicCaseDAO.findAll();
	}

	/*
	 * 查询一条记录（by id）
	 */
	public TbClassiccase findByID(String ccID) {
		if (ccID!=null) {
			return hmkClassicCaseDAO.findById(ccID);
		} else {
			return null;
		}
	}

	/*
	 * 新增或更新记录
	 */
	public void save(TbClassiccase tbClassiccase) {
		if (tbClassiccase!=null) {
			tbClassiccase.setA(IDUtil.PRESERVE);
			hmkClassicCaseDAO.attachDirty(tbClassiccase);
		}
	}

	public void setHmkClassicCaseDAO(HmkClassicCaseDAO hmkClassicCaseDAO) {
		this.hmkClassicCaseDAO = hmkClassicCaseDAO;
	}

}
